# coding=utf-8
"""
    @Author：SimpleTree
    @date：2025/5/10 15:06
    @desc: 
"""
from datetime import datetime

from api.db.db_models import APIToken, DB, API4Conversation
from api.db.services.common_service import CommonService
from api.utils import current_timestamp, datetime_format


class APITokenService(CommonService):
    model = APIToken

    @classmethod
    @DB.connection_context()
    def used(cls, token):
        return cls.model.update({
            "update_time": current_timestamp(),
            "update_date": datetime_format(datetime.now()),
        }).where(
            cls.model.token == token
        )


class API4ConversationService(CommonService):
    model = API4Conversation
